package cn.com.sqlite.demo.service.imp;

import java.awt.HeadlessException;
import java.util.Date;
import java.util.Random;

import javax.persistence.Transient;

import org.hibernate.id.IdentifierGenerationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.druid.util.Utils;
import com.sun.tools.internal.ws.wsdl.framework.ParseException;

import cn.com.sqlite.demo.common.annotation.SystemServiceLog;
import cn.com.sqlite.demo.dao.UserDao;
import cn.com.sqlite.demo.entity.po.log.UserPO;
import cn.com.sqlite.demo.service.UserService;

/**
* @Description: 用户信息业务接口实现类 
* @author Y.Jin
* @date 2017年2月7日 下午4:31:20
 */
@Service
public class UserServiceImp implements UserService {

	@Autowired
	private UserDao userDao;

	@SystemServiceLog(description="保存用户信息")
	public boolean add(UserPO po) throws Exception {
		int rate = new Random().nextInt(5);
		
		switch(rate){
		case 0:
			po.setCreate_time(new Date());
			po.setUpdate_time(new Date());
			return userDao.save(po);
		case 2:
			int b = 5/0;
			break;
		case 3:
			throw new IdentifierGenerationException("不要跟我说话");
		case 4:
			throw new ParseException("xxx");
		case 5:
			throw new HeadlessException("e bu zhidao ");
		}
		return false;
	}
	
	
	public static void main(String[] args) {
		
//		int i=1;
//		if(i++ == 6){
//			System.out.println(i%3);
//		}else{
//			System.out.println("no run");
//		}
		
		int i = 6;
		boolean isPass = 6 == i++ ;
		if(isPass)
		{
			System.out.println(i);
			System.out.println(i%3);
		}
		
		
		int b =  i++;
		
		
		System.out.println(b);
		int c = ++i;
		System.out.println(c);
//		
		
	}
	
	
	
}
